package com.txts.road.app.message.controller;

import com.txts.road.app.message.model.query.MessageQuery;
import com.txts.road.app.message.model.query.SessionsQuery;
import com.txts.road.app.message.model.vo.SessionMessagesVO;
import com.txts.road.app.message.model.vo.SessionsVO;
import com.txts.road.app.message.service.MessageSessionService;
import com.txts.base.common.domain.ResponseDTO;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;
import java.util.List;


/**
 * 消息会话前端控制层
 *
 * @author baoyr
 * @since 2025-07-17 10:45
 */
@Tag(name = "消息会话接口")
@RestController
@RequestMapping("/api/v1/message-session")
@RequiredArgsConstructor
public class MessageSessionController {
    private final MessageSessionService messageSessionService;

    /**
     * 获取会话列表
     */
    @Operation(summary = "获取会话列表")
    @GetMapping("/sessions")
    public ResponseDTO<List<SessionsVO>> getMessageSessions(@Valid @RequestBody SessionsQuery query) {
        return ResponseDTO.ok(messageSessionService.getMessageSessions(query));

    }

    /**
     * 获取会话消息列表
     */
    @Operation(summary = "获取会话消息列表")
    @GetMapping("/messages/list")
    public ResponseDTO<List<SessionMessagesVO>> getSessionMessages(@Valid @RequestBody MessageQuery query) {
        return ResponseDTO.ok(messageSessionService.getSessionMessages(query));
    }


}
